from rest_framework.generics import GenericAPIView
from rest_framework.mixins import ListModelMixin, RetrieveModelMixin, CreateModelMixin, UpdateModelMixin, DestroyModelMixin
from product.models import Product
from Apis.serializers import ProductModelSerializer
# from Drf_api.customMixin import ListModelMixin

class ProductListMixin(GenericAPIView, ListModelMixin, CreateModelMixin):
    queryset = Product.objects.all()
    serializer_class = ProductModelSerializer

    def get(self, request, *args, **kwargs):
        return self.list(request, *args, **kwargs)
    
    def post(self, request):
        return self.create(request)

class ProductDetailMixin(GenericAPIView, RetrieveModelMixin, UpdateModelMixin, DestroyModelMixin):
        queryset = Product.objects.all()
        serializer_class = ProductModelSerializer

        def get(self, request, *args, **kwargs):
            return self.retrieve(request,*args, **kwargs)
        
        def put(self, request,*args, **kwargs ):
            return self.update(request,*args, **kwargs)

        def delete(self, request,*args, **kwargs):
            return self.destroy(request,*args, **kwargs)